home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
cpp_libs
/
answrbok
/
7_10.lha
/
7_10
/
7_10q.h
< prev
next >
Wrap
Text File
|
1993-08-08
|
2KB
|
87 lines
* Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
* The C++ Answer Book */
* Tony Hansen */
* All rights reserved. */
/ modes for a process_queue
num qmodes
Q_WMODE, // context switch when full/empty
Q_ZMODE, // ignore objects when full/empty
Q_EMODE // error when full/empty
;
xtern char *qm_print(qmodes); // DELETE
/ queue manipulation
lass process_queue
riend queue_head;
riend queue_tail;
queue_head *q_head;
queue_tail *q_tail;
process_object *q_last;
unsigned q_max;
unsigned q_count;
process_queue(unsigned m, queue_head *qh, queue_tail *qt)
{ q_max = m; q_count = 0; q_head = qh; q_tail = qt; }
~process_queue()
{ if (q_count) error("delete queue with members"); }
;
lass queue_head : public process_object
riend queue_tail;
process_queue *qh_queue;
ublic:
qmodes qh_mode;
queue_head(qmodes = Q_WMODE, unsigned = 10000);
~queue_head();
process_object *get();
int unget(process_object*);
queue_tail *tail();
queue_head *cut();
void splice(queue_tail*);
// manipulate the maximum
unsigned rd_max() { return qh_queue->q_max; }
void set_max(unsigned m) { qh_queue->q_max = m; }
unsigned rd_count() { return qh_queue->q_count; }
int pending(); // does queue_head have an object?
// T <== rd_count() == 0
;
lass queue_tail : public process_object
riend queue_head;
process_queue *qt_queue;
ublic:
qmodes qt_mode;
queue_tail(qmodes = Q_WMODE, unsigned = 10000);
~queue_tail();
int put(process_object*);
queue_head *head();
queue_tail *cut();
void splice(queue_head*);
// manipulate the maximum
unsigned rd_max() { return qt_queue->q_max; }
void set_max(unsigned m) { qt_queue->q_max = m; }
unsigned rd_space()
{ return qt_queue->q_max - qt_queue->q_count; }
int pending(); // does queue_tail have room?
// T <== rd_space() == 0
;